Skip to content

chore: cleanup impl visibility and helpers#23

Merged
uqio merged 5 commits intomainfrom
chore/cleanup-impl-visibility-and-helpers
Apr 26, 2026
Merged

chore: cleanup impl visibility and helpers#23
uqio merged 5 commits intomainfrom
chore/cleanup-impl-visibility-and-helpers

Conversation

@uqio
Copy link
Copy Markdown
Collaborator

@uqio uqio commented Apr 26, 2026

No description provided.

uqio and others added 2 commits April 26, 2026 20:50
Resolves the two deferred Copilot findings on PR #20 review #4176623587.
Pure cleanup — zero behavior change.

**Copilot #4 — RGBA-plane bounds-check helper extraction.** Added two
`pub(super) fn` helpers in `src/sinker/mixed/mod.rs`:

- `rgba_plane_row_slice(buf, one_plane_start, one_plane_end, w, h)` —
  centralises the `one_plane_end.checked_mul(4)? + one_plane_start * 4
  + slice` pattern with `GeometryOverflow` reporting.
- `rgb_row_buf_or_scratch(rgb, rgb_scratch, ...)` — picks RGB plane
  slice when attached, else grows the scratch buffer; same overflow
  handling.

Refactored every `MixedSinker<F>::process` impl across the 6 child
modules (`planar_8bit` / `semi_planar_8bit` / `subsampled_4_*_high_bit`
/ `bayer`) to call the helpers instead of inlining the bounds-check +
slice math:

- Pattern A (RGB row buf-or-scratch): 37 substitutions across all 33
  process impls (wired + unwired families).
- Pattern B (standalone RGBA branch): 9 substitutions in the wired
  families (Yuv420p / Yuv422p / Yuv444p / Yuv440p / Nv12 / Nv16 / Nv21
  / Nv24 / Nv42).
- Pattern C (Strategy-A RGBA expand fan-out): 9 substitutions in the
  same wired families.

**Copilot #2 — `_impl` visibility tightening.** Dropped `pub(crate)`
from 23 of 24 `*_to_rgb_or_rgba_row[_impl]<...>` functions in
`src/row/scalar.rs` and the 5 SIMD backends. The single exception
kept `pub(crate)`: `scalar::yuv_420_to_rgb_or_rgba_row` — called by
all 5 SIMD backends as the scalar tail handler (verified by grep
across `src/row/arch/*.rs`).

**Diff:** 13 files changed, +434 / -1134 (net -700 lines). All
helpers and the visibility tightening shrink the production-facing
surface without touching any wire-level behaviour.

**Verified locally on aarch64 macOS:**
- 479 lib tests pass (unchanged).
- 1 doctest passes.
- `cargo check --lib --target wasm32-unknown-unknown`: clean.
- `cargo check --lib --target x86_64-unknown-linux-gnu`: clean.
- `cargo clippy --lib --tests`: 0 warnings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors MixedSinker row-processing implementations to reduce duplicated buffer-slicing logic and tightens internal kernel helper visibility in row backends.

Changes:

  • Introduces shared helpers in src/sinker/mixed/mod.rs for selecting RGB row output buffers and slicing RGBA row ranges.
  • Updates multiple MixedSinker<F>::process implementations to use the new helpers instead of repeated slicing/overflow-check patterns.
  • Narrows visibility of several internal *_to_rgb_or_rgba_* helpers in scalar/SIMD row implementations from pub(crate) to module-private.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/sinker/mixed/mod.rs Adds rgba_plane_row_slice and rgb_row_buf_or_scratch helpers to centralize duplicated logic.
src/sinker/mixed/planar_8bit.rs Replaces inline RGB/RGBA slicing logic with shared helpers.
src/sinker/mixed/semi_planar_8bit.rs Replaces inline RGB/RGBA slicing logic with shared helpers for NV* formats.
src/sinker/mixed/subsampled_4_2_0_high_bit.rs Uses rgb_row_buf_or_scratch for RGB row selection (but adds an unused import).
src/sinker/mixed/subsampled_4_2_2_high_bit.rs Uses rgb_row_buf_or_scratch for RGB row selection (but adds an unused import).
src/sinker/mixed/subsampled_4_4_4_high_bit.rs Uses rgb_row_buf_or_scratch for RGB row selection (but adds an unused import).
src/sinker/mixed/bayer.rs Uses rgb_row_buf_or_scratch for RGB row selection (but adds an unused import).
src/row/scalar.rs Makes shared scalar kernel helpers module-private.
src/row/arch/neon.rs Makes shared SIMD kernel helpers module-private.
src/row/arch/wasm_simd128.rs Makes shared SIMD kernel helpers module-private.
src/row/arch/x86_sse41.rs Makes shared SIMD kernel helpers module-private.
src/row/arch/x86_avx2.rs Makes shared SIMD kernel helpers module-private.
src/row/arch/x86_avx512.rs Makes shared SIMD kernel helpers module-private.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sinker/mixed/subsampled_4_2_0_high_bit.rs Outdated
Comment thread src/sinker/mixed/bayer.rs Outdated
Comment thread src/sinker/mixed/subsampled_4_4_4_high_bit.rs Outdated
Comment thread src/sinker/mixed/subsampled_4_2_2_high_bit.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sinker/mixed/mod.rs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@uqio uqio merged commit 6b96cc4 into main Apr 26, 2026
50 of 58 checks passed
@uqio uqio deleted the chore/cleanup-impl-visibility-and-helpers branch April 26, 2026 09:37
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants